﻿using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace GuangHaoJie.FMS.Domain
{
	
	public class BaseEntity<TKey>:IEquatable<TKey>
	{
		/// <summary>
		/// 
		/// </summary>
		[SugarColumn(ColumnName ="Id",IsPrimaryKey =true)]
		public TKey Id { get; set; }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="other"></param>
		/// <returns></returns>
		public bool Equals(TKey? other)
		{
			if (other!=null && (other.Equals(Id)|| other.ToString()==Id.ToString()))
			{
				return true;
			}
			return false;
		}
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			return JsonConvert.SerializeObject(this);
		}
	}
}
